/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PẻiodReportPnl.java
 *
 * Created on Jul 17, 2011, 10:59:31 PM
 */
package com.viweb.storemanager.report;

import com.jidesoft.swing.JideTabbedPane;
import com.viweb.storemanager.core.ColumnData;
import com.viweb.storemanager.core.DefaultObjectTableModel;
import com.viweb.storemanager.core.MyListCellRenderer;
import com.viweb.storemanager.core.ObjectComboBoxModel;
import java.util.Date;
import java.util.List;
import javax.swing.JTable;
import javax.swing.JViewport;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;

/**
 *
 * @author qhvic
 */
public class PeriodReportPnl extends javax.swing.JPanel {

    private JTable headerTablePayment;
    private JTable headerTableDrink;
    private List periods;

    /** Creates new form PẻiodReportPnl */
    public PeriodReportPnl() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        buttonGroup = new javax.swing.ButtonGroup();
        pnlMainFunction = new javax.swing.JPanel();
        tbpDailyReport = new JideTabbedPane();
        pnlPayments = new javax.swing.JPanel();
        scpPayment = new javax.swing.JScrollPane();
        tblPayment = new javax.swing.JTable();
        pnlDrinks = new javax.swing.JPanel();
        scpDrink = new javax.swing.JScrollPane();
        tblDrink = new javax.swing.JTable();
        btnView = new javax.swing.JButton();
        pnlSumary = new javax.swing.JPanel();
        lblTotal = new javax.swing.JLabel();
        btnPrint = new javax.swing.JButton();
        lblTime = new javax.swing.JRadioButton();
        cmbPeriod = new javax.swing.JComboBox();
        dateYear = new com.toedter.calendar.JYearChooser();
        radDay = new javax.swing.JRadioButton();
        dateStart = new com.toedter.calendar.JDateChooser();
        lblDay = new javax.swing.JLabel();
        dateFinish = new com.toedter.calendar.JDateChooser();

        setLayout(new java.awt.BorderLayout());

        pnlMainFunction.setLayout(new java.awt.GridBagLayout());

        tbpDailyReport.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Nội dung báo cáo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), java.awt.Color.blue));
        ((JideTabbedPane) tbpDailyReport).setTabShape(JideTabbedPane.SHAPE_DEFAULT);
        ((JideTabbedPane) tbpDailyReport).setBoldActiveTab(true);

        pnlPayments.setLayout(new java.awt.GridBagLayout());

        ColumnData[] columnsPayment = {new ColumnData("Số", 70, SwingConstants.LEFT, 1),
            new ColumnData("Bàn", 70, SwingConstants.LEFT, 2),
            new ColumnData("Vào", 50, SwingConstants.CENTER, 4),
            new ColumnData("Ra", 50, SwingConstants.CENTER, 5),
            new ColumnData("Ngày", 70, SwingConstants.CENTER, 11),
            new ColumnData("Giảm", 50, SwingConstants.CENTER, 6),
            new ColumnData("Thanh toán", 80, SwingConstants.RIGHT, 3, ColumnData.NUMBER_RENDERER),
            new ColumnData("Thu ngân", 150, SwingConstants.LEFT, 8),
            new ColumnData("Ghi chú", 180, SwingConstants.LEFT, 7)

        };
        DefaultObjectTableModel modelPayment = new DefaultObjectTableModel(tblPayment, columnsPayment, null, false);

        headerTablePayment = modelPayment.getHeaderTable();
        headerTablePayment.createDefaultColumnsFromModel();
        tblPayment.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

        // Put it in a viewport that we can control a bit
        JViewport viewportPayment = new JViewport();
        viewportPayment.setView(headerTablePayment);
        viewportPayment.setPreferredSize(headerTablePayment.getMaximumSize());

        scpPayment.setRowHeader(viewportPayment);
        scpPayment.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, headerTablePayment
            .getTableHeader());
        scpPayment.setViewportView(tblPayment);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        pnlPayments.add(scpPayment, gridBagConstraints);

        tbpDailyReport.addTab("Theo hoá đơn", pnlPayments);

        pnlDrinks.setLayout(new java.awt.GridBagLayout());

        ColumnData[] columnsDrink = {new ColumnData("Tên thức uống", 150, SwingConstants.LEFT, 1),
            new ColumnData("Số lượng", 100, SwingConstants.CENTER, 7),
            new ColumnData("Đơn giá", 100, SwingConstants.RIGHT, 5, ColumnData.NUMBER_RENDERER),
            new ColumnData("Thành tiền", 150, SwingConstants.RIGHT, 8, ColumnData.NUMBER_RENDERER)
        };
        DefaultObjectTableModel modelDrink = new DefaultObjectTableModel(tblDrink, columnsDrink, null, false);

        headerTableDrink = modelDrink.getHeaderTable();
        headerTableDrink.createDefaultColumnsFromModel();
        tblDrink.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

        // Put it in a viewport that we can control a bit
        JViewport viewportDrink = new JViewport();
        viewportDrink.setView(headerTableDrink);
        viewportDrink.setPreferredSize(headerTableDrink.getMaximumSize());

        scpDrink.setRowHeader(viewportDrink);
        scpDrink.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, headerTableDrink
            .getTableHeader());
        scpDrink.setViewportView(tblDrink);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        pnlDrinks.add(scpDrink, gridBagConstraints);

        tbpDailyReport.addTab("Theo thức uống", pnlDrinks);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 8;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
        pnlMainFunction.add(tbpDailyReport, gridBagConstraints);

        btnView.setText("Xem");
        btnView.setMinimumSize(new java.awt.Dimension(80, 25));
        btnView.setPreferredSize(new java.awt.Dimension(80, 25));
        btnView.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 7;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        pnlMainFunction.add(btnView, gridBagConstraints);

        pnlSumary.setLayout(new java.awt.GridBagLayout());

        lblTotal.setFont(new java.awt.Font("Tahoma", 1, 12));
        lblTotal.setText("Tổng cộng:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        pnlSumary.add(lblTotal, gridBagConstraints);

        btnPrint.setText("Xem/In báo cáo");
        btnPrint.setMinimumSize(new java.awt.Dimension(128, 25));
        btnPrint.setPreferredSize(new java.awt.Dimension(128, 25));
        btnPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrintActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        pnlSumary.add(btnPrint, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 8;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        pnlMainFunction.add(pnlSumary, gridBagConstraints);

        lblTime.setSelected(true);
        lblTime.setText("Thời gian:");
        lblTime.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        lblTime.setMargin(new java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        pnlMainFunction.add(lblTime, gridBagConstraints);

        cmbPeriod.setMinimumSize(new java.awt.Dimension(100, 25));
        cmbPeriod.setPreferredSize(new java.awt.Dimension(100, 25));
        ObjectComboBoxModel modelPeriod = new ObjectComboBoxModel(this.periods);
        cmbPeriod.setModel(modelPeriod);
        cmbPeriod.setRenderer(new MyListCellRenderer());
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        pnlMainFunction.add(cmbPeriod, gridBagConstraints);

        dateYear.setMinimumSize(new java.awt.Dimension(50, 25));
        dateYear.setPreferredSize(new java.awt.Dimension(50, 25));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(6, 5, 0, 0);
        pnlMainFunction.add(dateYear, gridBagConstraints);

        radDay.setText("Từ ngày:");
        radDay.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        radDay.setMargin(new java.awt.Insets(0, 0, 0, 0));
        radDay.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                radDayItemStateChanged(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(5, 20, 0, 0);
        pnlMainFunction.add(radDay, gridBagConstraints);

        dateStart.setDate(new Date());
        dateStart.setDateFormatString("dd/MM/yyyy");
        dateStart.setEnabled(false);
        dateStart.setMinimumSize(new java.awt.Dimension(90, 25));
        dateStart.setPreferredSize(new java.awt.Dimension(90, 25));
        dateStart.setLocale(new java.util.Locale("vi"));
        dateStart.setDateFormatString("dd/MM/yyyy");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        pnlMainFunction.add(dateStart, gridBagConstraints);

        lblDay.setText("đến ngày:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 0);
        pnlMainFunction.add(lblDay, gridBagConstraints);

        dateFinish.setDate(new Date());
        dateFinish.setDateFormatString("dd/MM/yyyy");
        dateFinish.setEnabled(false);
        dateFinish.setMinimumSize(new java.awt.Dimension(90, 25));
        dateFinish.setPreferredSize(new java.awt.Dimension(90, 25));
        dateFinish.setLocale(new java.util.Locale("vi"));
        dateFinish.setDateFormatString("dd/MM/yyyy");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        pnlMainFunction.add(dateFinish, gridBagConstraints);

        add(pnlMainFunction, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

    private void btnViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewActionPerformed
}//GEN-LAST:event_btnViewActionPerformed

    private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed
}//GEN-LAST:event_btnPrintActionPerformed

    private void radDayItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_radDayItemStateChanged
}//GEN-LAST:event_radDayItemStateChanged
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnPrint;
    private javax.swing.JButton btnView;
    private javax.swing.ButtonGroup buttonGroup;
    private javax.swing.JComboBox cmbPeriod;
    private com.toedter.calendar.JDateChooser dateFinish;
    private com.toedter.calendar.JDateChooser dateStart;
    private com.toedter.calendar.JYearChooser dateYear;
    private javax.swing.JLabel lblDay;
    private javax.swing.JRadioButton lblTime;
    private javax.swing.JLabel lblTotal;
    private javax.swing.JPanel pnlDrinks;
    private javax.swing.JPanel pnlMainFunction;
    private javax.swing.JPanel pnlPayments;
    private javax.swing.JPanel pnlSumary;
    private javax.swing.JRadioButton radDay;
    private javax.swing.JScrollPane scpDrink;
    private javax.swing.JScrollPane scpPayment;
    private javax.swing.JTable tblDrink;
    private javax.swing.JTable tblPayment;
    private javax.swing.JTabbedPane tbpDailyReport;
    // End of variables declaration//GEN-END:variables
}
